<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>计数器</title>
</head>


<body>
    <div id="app">
        <h2>当前计数:{{counter}}</h2>
    <button @click="increment">+</button>
    <button @click="decrement">-</button>
    </div>
</body>
<script src="https://unpkg.com/vue@next"></script>
<script>
    const app = {
        data() {
            return {
                counter: 0
            }
        },
        methods: {
            increment() {
                this.counter++
                console.log("被执行");
            },
            decrement() {
               if(this.counter > 0){
                   this.counter--
               }else{
                   return 
               }
            }
        },

    }
    Vue.createApp(app).mount("#app");
</script>

</html>